// 给定一个先递增后递减的数组，找最大值
// 1, 2, 3, 4, 3, 2, 1
var maxnum = function(arr) {
    let left = 0, right = arr.length - 1
    while(left < right) {
        let mid = Math.floor((left + right + 1) / 2)
        if(arr[mid] >= arr[mid - 1]) {
            left = mid
        } else if(arr[mid] <= arr[mid - 1]) {
            right = mid - 1
        }
    }
    return arr[left]
}
console.log(maxnum([1, 2, 3, 4, 3, 2, 1]));
console.log(maxnum([1, 2, 3, 3, 3, 4, 4, 4, 3, 2, 1]));
console.log(maxnum([1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 2]));
// 3 3 3